package com.zcs.app.base.dialog

import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.FragmentActivity

object CustomDialogHelper {
    fun dismissDialog(alertDialog: AlertDialog?) {
        try {
            if (alertDialog != null && alertDialog.isShowing) alertDialog.dismiss()
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    fun showCustomMessageDialog(activity: FragmentActivity, msg: String?) {
        if (msg.isNullOrEmpty()) return
    }

    fun showCustomMessageDialog(
        activity: FragmentActivity,
        param: DialogParam,
        callback: NativeDialogCallback
    ) {

    }

    fun showCustomConfirmDialog(
        activity: FragmentActivity,
        param: DialogParam,
        callback: NativeDialogCallback
    ) {

    }
}

class DialogParam {
    var title = ""
    var message = "您确定要这么做吗？"
    var positiveBtnText = "确定"
    var negativeBtnText = "取消"
    var advMessage: CharSequence? = null
    var isShowCloseIcon = false
    var isCenterContent = true // 默认居中
    var isCancelAble = false // 默认居中
    var isHideBtns = false // 隐藏按钮组

    constructor() {}
    constructor(message: String) {
        this.message = message
    }

    constructor(advMessage: CharSequence?) {
        this.advMessage = advMessage
    }

    constructor(title: String, message: String) {
        this.title = title
        this.message = message
    }

    constructor(title: String, message: String, positiveBtnText: String, negativeBtnText: String) {
        this.title = title
        this.message = message
        this.positiveBtnText = positiveBtnText
        this.negativeBtnText = negativeBtnText
    }
}

interface NativeDialogCallback {
    fun onConfirm()
    fun onCancel()
}

abstract class CustomDialogCallbackAdapter : NativeDialogCallback {
    override fun onCancel() {}
}